# Django settings for ejejeweb project.
# -*- encoding: utf-8 -*-
############################################################################
#    Copyright (C) 2007-2010 by Håvard Gulldah                             #
#    havard@gulldahl.no                                                    #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

import os.path, sys
BASE_DIR = os.path.abspath(os.path.dirname(__file__))

DEVELOPMENT_MODE = os.path.exists(BASE_DIR + '/_DEVELOPMENT_MODE')
DEBUG = os.path.exists(BASE_DIR + '/_DEBUG')
TEMPLATE_DEBUG = DEBUG


ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
    (u'Håvard Gulldahl', 'havard@lurtgjort.no'),
)

MANAGERS = ADMINS

DATABASES = {
    'test': {
        'ENGINE': 'django.db.backends.sqlite3',           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': BASE_DIR+'/ejeje.db',            # Or path to database file if using sqlite3.
        'USER': 'havard',            # Not used with sqlite3.
        'HOST': 'localhost',             # Set to empty string for localhost. Not used with sqlite3.
        'PORT': ''             # Set to empty string for default. Not used with sqlite3.
    },
    'dev': {
        'ENGINE': 'django.db.backends.mysql',           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'ejeje',            # Or path to database file if using sqlite3.
        'USER': 'ejeje',            # Not used with sqlite3.
        #'HOST': '192.168.0.100',             # Set to empty string for localhost. Not used with sqlite3.
        'HOST': '',             # Set to empty string for localhost. Not used with sqlite3.
        'PORT': ''             # Set to empty string for default. Not used with sqlite3.
    },
    'production': {
        'ENGINE': 'django.db.backends.mysql',           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'ejeje',            # Or path to database file if using sqlite3.
        'USER': 'ejeje',            # Not used with sqlite3.
        #'HOST': '192.168.0.100',             # Set to empty string for localhost. Not used with sqlite3.
        'HOST': '',             # Set to empty string for localhost. Not used with sqlite3.
        'PORT': ''             # Set to empty string for default. Not used with sqlite3.
    }

}

DATABASES['default'] = DATABASES['dev'] if DEVELOPMENT_MODE else DATABASES['production']

try:
  DATABASES['default']['PASSWORD'] = open('dbpass.txt').readline().strip()
except:
  pass


    

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Oslo'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
if DEVELOPMENT_MODE:
  MEDIA_ROOT = BASE_DIR + '/media/'
else:
  MEDIA_ROOT = '/home/users/lurtgjort/var/ejeje/ejejeweb/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin_media/'

# Make this unique, and don't share it with anybody.
try:
    SECRET_KEY = open('secretkey.txt').readline().strip()
except:
    SECRET_KEY = None
    
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader')


MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'ejejeweb.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    BASE_DIR + '/templates',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'ejejeweb.ejeje',
)

import logging
loglevel = logging.ERROR
if DEVELOPMENT_MODE:
    INTERNAL_IPS = (
        '127.0.0.1', '0.0.0.0'
    )
    loglevel = logging.DEBUG
    
logging.basicConfig(level=loglevel)
